define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    const Controller = {
        index: function () {
            new Vue({
                el: "#goodsAccessIndex",
                data() {
                    return {
                        chooseType : 0,
                        created_at : '',//查询时间
                        data       : [],
                        offset     : 0,
                        limit      : 10,
                        totalPage  : 0,
                        currentPage: 1,
                    }
                },
                created() {
                    this.getData()
                },
                methods: {
                    getData() {
                        let that = this;
                        Fast.api.ajax({
                            url    : 'health/goods/goods_access/index',
                            loading: true,
                            type   : 'GET',
                            data   : {
                                created_at: this.created_at,
                                offset    : that.offset,
                                limit     : that.limit,
                            },
                        }, function (ret, res) {
                            that.data = res.data.rows;
                            that.data.forEach(i => {
                                i.visible = false;
                            })
                            that.totalPage = res.data.total;
                            return false;
                        })
                    },
                    isChoose() {
                    },
                    operation(type, id) {
                        let that = this;
                        switch (type) {
                            case 'filter':
                                this.getData()
                                break;
                            case 'clear':
                                this.created_at = '';
                                break;
                        }
                    },
                    handleSizeChange(val) {
                        this.offset = 0
                        this.limit = val;
                        this.currentPage = 1;
                        this.getData()
                    },
                    handleCurrentChange(val) {
                        this.currentPage = val;
                        this.offset = (val - 1) * this.limit;
                        this.getData()
                    },
                    tableRowClassName({rowIndex}) {
                        if (rowIndex % 2 === 1) {
                            return 'bg-color';
                        }
                        return '';
                    },
                    tableCellClassName({columnIndex}) {
                        if (columnIndex === 2 || columnIndex === 9) {
                            return 'cell-left';
                        }
                        return '';
                    },
                },
            })
        }
    };
    return Controller;
});